#pragma once

#include "BaseObject.hpp"

class D3dTexture;

class Material : public BaseObject
{
public:
	enum TYPE
	{
		TYPE_NORMAL,
		TYPE_EMISSIVE,
		TYPE_TRANSLUCENT,
	};

	TYPE Type;
	D3DCULL CullMode;
	D3DFILLMODE FillMode;
	bool CastShadow;
	
	////// Only for TYPE_TRANSLUCENT
	D3DBLENDOP BlendOp;
	D3DBLEND SrcBlend, DstBlend;

	bool AlphaTestEnabled;
	float AlphaTestRef;
	//D3DCMPFUNC AlphaTestFunc;

	bool ConstantColorEnabled;
	COLORF ConstantColor;
	bool VertexColorEnabled;

	float SpecularIntensity;
	float SpecularExponent;

	bool FresnelEnabled;
	COLORF FresnelColor;
	float FresnelExponent;

	bool EnvMappingEnabled;
	COLORF EnvMappingColor;
	
	bool NormalMappingEnabled;

	Material();

	bool IsUsingFresnel();
	bool IsUsingEnvMapping();
	bool IsUsingAlphaTest();
	uint CalcRenderingPasses(); // Returns RENDER_PASS_ flags.

	D3dTexture * GetTexture() { return m_Texture; }
	D3dTexture * GetEnvMappingTexture() { return m_EnvMappingTexture; }
	D3dTexture * GetNormalTexture() { return m_NormalTexture; }
	void SetTexture(D3dTexture *v);
	void SetNormalTexture(D3dTexture *v);
	void SetEnvMappingTexture(D3dTexture *v);

protected:
	virtual ~Material();

private:
	D3dTexture *m_Texture, *m_EnvMappingTexture, *m_NormalTexture;
};
